<%@page import="com.chauncy.DMS.bean.StuInfoBean"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<%
		List<Map<String,Object>> sDormInfoListMap= (List)session.getAttribute("sDormInfoListMap");
		System.out.println("welcome"+sDormInfoListMap );
 %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
		<meta charset="UTF-8">
		<title>首页</title>
		<link rel="stylesheet" href="../layui/css/layui.css" />
		<link rel="stylesheet" href="../css/stu_fun_page.css" />
		<script type="text/javascript" src="../jquery-3.3.1/jquery-3.3.1.min.js" ></script>
	</head>
	<body style="background: #e6e6e6;">
		<div class="layui-row">
			<table class="layui-table" lay-even lay-skin="nob">
				<colgroup>
					<col width="20%" />
					<col width="20%" />
					<col width="20%" />
					<col />
				</colgroup>
				<%if(sDormInfoListMap.size() > 0){%>
				<thead>
					<tr>
						<th>姓名</th>
						<th>学号</th>
						<th>学院</th>
						<th>专业</th>
						<th>班级</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td><%=sDormInfoListMap.get(0).get("Stu_name") %></td>
						<td><%=sDormInfoListMap.get(0).get("Stu_number") %></td>
						<td><%=sDormInfoListMap.get(0).get("College") %></td>
						<td><%=sDormInfoListMap.get(0).get("Study_major") %></td>
						<td><%=sDormInfoListMap.get(0).get("Class") %></td>
					</tr>
				</tbody>
				<thead>
					<tr>
						<th>管理员</th>
						<th>楼栋号</th>
						<th>宿舍号</th>
						<th>宿舍管理员</th>
						<th>DM联系方式</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td><%=sDormInfoListMap.get(0).get("Manager_name") %></td>
						<td><%=sDormInfoListMap.get(0).get("Dormitory_number") %></td>
						<td><%=sDormInfoListMap.get(0).get("Dorm_number") %></td>
						<td><%=sDormInfoListMap.get(0).get("Manager_name") %></td>
						<td><%=sDormInfoListMap.get(0).get("mTelephone") %></td>
					</tr>
				</tbody>
				<%}else{ %>
				<thead>
					<tr>
						<th>姓名</th>
						<th>学号</th>
						<th>学院</th>
						<th>专业</th>
						<th>班级</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td></td>
						<td>201610310000</td>
						<td>信息工程</td>
						<td>软件技术</td>
						<td>软件1600</td>
					</tr>
				</tbody>
				<thead>
					<tr>
						<th>管理员</th>
						<th>楼栋号</th>
						<th>宿舍号</th>
						<th>宿舍管理员</th>
						<th>DM联系方式</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td>Super-Manager</td>
						<td>三栋</td>
						<td>3-000</td>
						<td>Dorm-Manager</td>
						<td>183xxxxxxxx</td>
					</tr>
				</tbody>
				<%} %>
			</table>
		</div>
			<div class="layui-row">
				<div class="layui-col-md3">
					<a href="javascript:;">
							<span><i class="layui-icon layui-icon-face-surprised" style="font-size: 50px; color: yellow;"></i></span>
							<div class="col-right-text">
								<h3>本月请假次数</h3>
							</div>
							<div class="col-right-nub"><p style="color: yellow;" id="qingjia">100</p></div>
					</a>
				</div>
				<div class="layui-col-md3">
					<a href="javascript:;">
						<span><i class="layui-icon layui-icon-face-cry" style="font-size: 50px;color: orange;"></i></span>
						<div class="col-right-text">
							<h3>本月晚归次数</h3>
						</div>
						<div class="col-right-nub"><p style="color: orange;"  id="wangui">100</p></div>
					</a>
				</div>
				<div class="layui-col-md3">
					<a href="javascript:;">
						<span><i class="layui-icon layui-icon-tips" style="font-size: 50px; color: red;"></i></span>
						<div class="col-right-text">
							<h3>本月未归次数</h3>
						</div>
						<div class="col-right-nub"><p style="color: red;"  id="weigui">100</p></div>
					</a>
				</div>
				<div class="layui-col-md3">
					<a href="javascript:;">
						<span><i class="layui-icon layui-icon-list" style="font-size: 50px; color: deepskyblue;"></i></span>
						<div class="col-right-text">
							<h3>本月卫生扣分</h3>
						</div>
						<div class="col-right-nub"><p style="color: deepskyblue;" id="health">100</p></div>
					</a>
				</div>
			</div>
			<div class="layui-row" >
				<table class="layui-table"  lay-filter="stuAttTable" id="stuAttTable"></table>
			</div>
		<script type="text/javascript" src="../layui/layui.js" ></script>
		<script type="text/javascript">
		var stuId = <%=sDormInfoListMap.get(0).get("Stu_number") %>;
		var dNub = <%=sDormInfoListMap.get(0).get("Dorm_number") %>;
		getQingjiaCount(stuId);
		getWanGuiCount(stuId);
		getWeiGuiCount(stuId);
		getHealthInfoCount(dNub);
		function getQingjiaCount(stuId){
				$.ajax({
					type:"get",
					url:"../stuAttCountServlet",
					async:true,
					data:{
						stuId:stuId,
						flag:"qingjia"
						},
					success : function(data){
					console.log(data);
						$("#qingjia").html(data);
					}
				});
			}
			
			function getWanGuiCount(stuId){
				$.ajax({
					type:"get",
					url:"../stuAttCountServlet",
					async:true,
					data:{
						stuId:stuId,
						flag:"wangui"
					},
					success : function(data){
					console.log(data);
						$("#wangui").html(data);
					}
					
				});
			}
			
			function getWeiGuiCount(stuId){
				$.ajax({
					type:"get",
					url:"../stuAttCountServlet",
					async:true,
					data:{
						stuId:stuId,
						flag:"weigui"
						},
					success : function(data){
					console.log(data);
						$("#weigui").html(data);
					}
					
				});
			}
			
			function getHealthInfoCount(dNub){
				$.ajax({
					type:"get",
					url:"../stuAttCountServlet",
					async:true,
					data:{
						dNub:dNub,
						flag:"healthInfo"
						},
					success : function(data){
					console.log(data);
						$("#health").html(data);
					}
				});
			}
			
			
			layui.use('table',function(){
				var table = layui.table;
				table.render({
					elem:'#stuAttTable',
					height:315,
					
					url:'../stuAttCountServlet',
					where:{flag:'allAtt',stuId:stuId},
					limit:20,	
					cols:[[
						{field : 'Is_leave', title : '请假记录', width:100},
						{field:'Time_for_leave',title:'请假时间',width:200,sort:true},
						{field:'Stay_out_late',title:'晚归记录',width:100},
						{field:'Late_return_time',title:'晚归时间',width:100,sort:true},
						{field:' No_return',title:'未归记录',width:100},
						{field:'remarks',title:'备注',width:200},
						{field:'Att_date',title:'考勤时间',width:200,sort:true}
					]],
					response: {
				      		statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0  
				    	}
					    ,parseData: function(res){ //将原始数据解析成 table 组件所规定的数据
					      return {
					        "code": res.status, //解析接口状态
					        "msg": res.message, //解析提示文本
					        "count": res.datasize, //解析数据长度
					        "data": res.rows.item //解析数据列表
					      };
					    }
				});
				
			});
			
		</script>
	</body>
</html>
